package com.alnex.drools.controller;
import com.alnex.drools.service.ReloadDroolsRules;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class ReloadController {

    @Autowired
    private ReloadDroolsRules reloadDroolsRules;

    @GetMapping("reload/{drlName}")
    public Object reload(@PathVariable("drlName") String drlName) throws Exception {
        reloadDroolsRules.reload(drlName);

        return "重新加载 DRL 文件";
    }

    @PostMapping("/updateDrlFile")
    public String updateDrlFile(MultipartFile file) throws Exception {
        //更新drl后，再调用reload方法重载。即可热部署
        return "ok";
    }
}
